﻿using System;
using System.Collections.Generic;
using System.Text;
using Slaks.Graphs.GraphBuilder;
namespace Slaks.Graphs.Algorithms.DistanceAlgorithm
{
    public class DistWGUVertexEdgeCountExtended : GraphDistanceBase
    {
        public DistWGUVertexEdgeCountExtended () : base ()
        {
			IsVisible = true;
        }

        public DistWGUVertexEdgeCountExtended(Graph one, Graph two) 
            : base ( one, two )
        {
			IsVisible = true;
        }
		public override bool CanOperateOnRepresentation (GraphBuilder.BuilderType builderType)
		{
			switch(builderType)
			{
				case BuilderType.StandardRepresentationSchenker:
case BuilderType.ExtractorBuilderNodesOnly:
case BuilderType.StandardRepresentationSlaks:
case BuilderType.SimpleRepresentationSchenker:
case BuilderType.SimpleRepresentationSlaks:
case BuilderType.NDistanceRepresentationSchenker:
case BuilderType.NDistanceRepresentationSlaks:
case BuilderType.NSimpleDistanceRepresentationSchenker:
case BuilderType.NSimpleDistanceRepresentationSlaks:
				return true;
			}
			return false;
		}
        public override double GetDistance()
        {
            long mcsSize = one.GetMCS(two).GetGraphSizeVertexEdgeCount;
            if (mcsSize == 0) return 1;
            if (mcsSize == one.GetGraphSizeVertexEdgeCount && mcsSize == two.GetGraphSizeVertexEdgeCount) return 0;
            return 1 - (double)mcsSize / (one.GetGraphSizeVertexEdgeCount + two.GetGraphSizeVertexEdgeCount - 2 * mcsSize);
        }
    }
}
